package testCase.module1;

import android.util.Log;
import testCase.HeadTestCase;
import utils.MyTestResult;
import utils.UserInfo_Properties;

public class NO_005_CodeEditText extends HeadTestCase {

	MyTestResult t = new MyTestResult();
	String errorCode = "123";

	public NO_005_CodeEditText() {
		try {
			super.setUp();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	// 输入正确的电话号码，验证码输入框为空，验证确认按钮是否可以点击
	public void test_001_isClick() throws Exception {
		Log.d(TAG, solo.waitForText("^开始使用$") + "++" + getName());

		entrance.getStart_Page().click_btn_start();
		solo.sleep(500);
		Log.e(TAG, "wait for view:" + solo.waitForView(entrance.getLogin_page().getBtn_ok()));

		entrance.getLogin_page().enter_PhoneNumber(
				UserInfo_Properties.getValue(UserInfo_Properties.MANERGERTEACHER_PHONENUMBER));

		if (!entrance.getLogin_page().getBtn_ok().isEnabled()) {
			Log.d(TAG, "view is can't click");
			t.printTestResultToExcel(cl_Name + getName(), "输入正确的电话号码，验证码输入框为空，验证确认按钮是否可以点击", "无法点击", "pass");
		} else {
			Log.d(TAG, "view could click");
			t.printTestResultToExcel(cl_Name + getName(), "输入正确的电话号码，验证码输入框为空，验证确认按钮是否可以点击", "无法点击", "fail");
			assertTrue(false);
		}
	}

	// 输入正确的电话号码，点击发送验证码按钮，输入错误的验证码，点击确认按钮
	public void test_002_ClickOk() throws Exception {
		Log.d(TAG, solo.waitForText("^开始使用$") + "++" + getName());

		entrance.getStart_Page().click_btn_start();
		solo.sleep(500);
		Log.e(TAG, "wait for view:" + solo.waitForView(entrance.getLogin_page().getBtn_ok()));

		entrance.getLogin_page().enter_PhoneNumber(
				UserInfo_Properties.getValue(UserInfo_Properties.MANERGERTEACHER_PHONENUMBER));
		entrance.getLogin_page().click_btn_verify();

		if (solo.waitForText("验证码将发送到"+UserInfo_Properties.getValue(UserInfo_Properties.MANERGERTEACHER_PHONENUMBER))
				&&solo.waitForText("发送验证码", 1, 5000)) {
			solo.clickOnText("^是$");
		} else {
			t.printTestResultToExcel(cl_Name + getName(), "正确的电话号码，点击验证码按钮", "弹出确认电话号码提示", "fail");
			Log.e(TAG, "未弹出确认电话号码提示");
			assertTrue(false);
		}

		entrance.getLogin_page().enter_verifyCode(errorCode);
		entrance.getLogin_page().clickOn_BtOk();

		if (solo.searchText("登录错误,请重新发送验证码后再进行登录!")) {
			Log.d(TAG, cl_Name + ":搜索到验证码错误提示");
			t.printTestResultToExcel(cl_Name + getName(), "输入正确的电话号码，点击发送验证码按钮，输入错误的验证码，点击确认按钮", "toast提示验证码错误",
					"pass");
		} else {
			Log.e(TAG, cl_Name + ":未搜索到验证码错误提示");
			t.printTestResultToExcel(cl_Name + getName(), "输入正确的电话号码，点击发送验证码按钮，输入错误的验证码，点击确认按钮", "toast提示验证码错误",
					"fail");
			assertTrue(false);
		}
	}
}
